package com.lrkj.web.phone;

import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.core.page.TableDataInfo;
import com.lrkj.payfee.domain.ChargeItem;
import com.lrkj.payfee.domain.PayOrder;
import com.lrkj.payfee.service.IChargeItemService;
import com.lrkj.payfee.service.IPayOrderService;
import com.lrkj.payfee.service.IRuleCostService;
import com.lrkj.payfee.service.IWxPayfeeService;
import com.lrkj.payfee.vo.BillPaymentVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "手机端收费信息")
public class PayfeeControll extends BaseController {

    @Autowired
    private IRuleCostService ruleCostService;

    @Autowired
    private IWxPayfeeService wxPayfeeService;

    @Autowired
    private IPayOrderService payOrderService;

    @Autowired
    private IChargeItemService chargeItemService;

    /**
     * 房间欠费金额
     */
    @ApiOperation(value = "房间欠费金额", notes = "房间欠费金额")
    @GetMapping(value = "/phone/payfee/roomAmountOwed/{roomId}")
    public AjaxResult roomAmountOwed(@ApiParam(name = "房间ID", value = "roomId", required = true) @PathVariable("roomId") String roomId) {
        return AjaxResult.success(ruleCostService.roomAmountOwed(roomId));
    }


    /**
     * 房间账单明细
     */
    @ApiOperation(value = "房间账单明细", notes = "房间账单明细")
    @GetMapping(value = "/phone/payfee/billDetail/{roomId}")
    public AjaxResult billDetail(@ApiParam(name = "房间ID", value = "roomId", required = true) @PathVariable("roomId") String roomId) {
        return AjaxResult.success(ruleCostService.roomBillDetail(roomId));
    }


    /**
     * 房间账单缴费
     */
    @ApiOperation(value = "房间账单缴费", notes = "房间账单缴费")
    @PostMapping(value = "/phone/payfee/billPayment")
    public AjaxResult billPayment(@RequestBody BillPaymentVo billPaymentVo) {
        return toAjax(wxPayfeeService.payment(billPaymentVo));
    }


    /**
     * 房间缴费记录
     */
    @ApiOperation(value = "房间缴费记录", notes = "房间缴费记录")
    @GetMapping(value = "/phone/payfee/paymentRecord")
    public TableDataInfo paymentRecord(PayOrder payOrder) {
        startPage();
        return getDataTable(payOrderService.selectPayOrderList(payOrder));
    }


    @ApiOperation(value = "房间收费项目", notes = "房间收费项目")
    @GetMapping(value = "/phone/payfee/chargeItem")
    public TableDataInfo chargeNormList(ChargeItem chargeItem) {
        chargeItem.setProjectIdIN("01,02");
        List<ChargeItem> list = chargeItemService.selectChargeItemList(chargeItem);
        return getDataTable(list);
    }


}
